﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Windows.Controls.DataVisualization.Charting;

namespace Powerpoint
{
    /// <summary>
    /// Interaktionslogik für Statistics_Window.xaml
    /// </summary>
    public partial class Statistics_Window : Window
    {
        Statistics stats = new Statistics();

        public Statistics_Window(Statistics statistics)
        {
            stats = statistics;
            InitializeComponent();
            LoadChartData();
            LoadAndCalcMotionAverage();
            LoadAndCalcVolumeAverage();
        }

        private void LoadAndCalcVolumeAverage()
        {
            float average = stats.volumeSum / stats.volumeHistory.Keys.Count;
            averageVolumeText.Content += average.ToString();
        }

        private void LoadChartData()
        {
            ((LineSeries)statsChart.Series[0]).ItemsSource = stats.motionHistory;
            ((LineSeries)statsChart.Series[1]).ItemsSource = stats.volumeHistory;
            ((ColumnSeries)notificationStatsChart.Series[0]).ItemsSource = stats.notificationHistory;
            ((LineSeries)notificationStatsChart.Series[1]).ItemsSource = stats.totalNotificationHistory;


        }


        private void LoadAndCalcMotionAverage()
        {
            float average = stats.motionSum / stats.motionHistory.Keys.Count;
            averageMotionText.Content += average.ToString();
        }
    }
}
